/*
 * FindBugs - Find Bugs in Java programs
 * Copyright (C) 2003-2008 University of Maryland
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package edu.umd.cs.findbugs.gui2;

import java.awt.Component;
import java.io.File;

import edu.umd.cs.findbugs.BugCollection;
import edu.umd.cs.findbugs.Project;

/**
 * This class is intended to provide a seam between MainFrame and some of the separated components
 * which have been refactored out into separate classes. It should allow the control over the GUI
 * application which is provided by MainFrame. Since the situation in which I separated MainFrame
 * did not provide a single, consistent, cohesive view of MainFrame which would have made sense to
 * make into smaller abstraction units, several things have been lumped together. At least providing
 * a layer of indirection between the concrete MainFrame is a start.
 * 
 * @see MainFrame
 * @author graham
 */
public interface IApplicationState extends DisplayIssueDecider {

	void saveComments();

	void syncBugInformation();

	void setProjectChanged(boolean beforeProjectChanged);

	boolean projectChanged();

	void updateDesignationDisplay();

	void setUserCommentInputEnable(boolean b);

	BugLeafNode currentSelectedBugLeaf();

	BugAspects currentSelectedBugAspects();

	/**
	 * Analysis changes include anything which alter the state of the current analysis. This
	 * includes, but is not limited to: <br>
	 * <ul>
	 * <li>Opening a new project</li>
	 * <li>Redoing analysis</li>
	 * <li>A user designating a bug</li>
	 * </ul>
	 */
	public interface AnalysisChangeListener {
		void notifyAnalysisChanged();
	}

	void addProjectChangeListener(AnalysisChangeListener toAdd);

	void removeProjectChangeListener(AnalysisChangeListener toRemove);

	BugCollection bugCollection();

	Project getProject();

	/**
	 * The UIFactory is a wrapper for several different parts of the Findbugs GUI2 which are
	 * depended upon across the application. Rather than reference singletons all over the place,
	 * the dependency should be modelled by accepting an instance of {@link UIFactory} and
	 * retrieving the necessary widgets from that.
	 * 
	 * Classes should take care not to hold on to the result of any of the methods used here, and
	 * instead ask for the UI widget each time it is required, as the reference may be updated at
	 * any point.
	 */
	public interface UIFactory {
		FilterActivity filterActivity();

		PreferencesFrame preferencesFrame();

		@SuppressWarnings("deprecation")
		ProjectSettings projectSettings();

		void createNewProjectSettings();
		
		Component dialogParent();
		
		void setFontSize(float size);
		void setFontSizeHelper(float size, Component... comps);
		
		void showMessageDialog(String message);
	}

	UIFactory uiFactory();

	File getSaveFile();

}
